<?php
namespace App\Http\Controllers\API;
/**
 * Created by PhpStorm.
 * User: 都大爽
 * Date: 2017/8/1
 * Time: 9:30
 */
use App\Http\Controllers\Controller;
use App\Models\WorksType;
use Illuminate\Support\Facades\Cache;

class WorksTypeController extends Controller
{
    /**
     * 获取作品类别下拉列表
     * @return mixed
     */
    public function getSelectList()
    {
        $selectList = Cache::remember('works-type-select-list', 120, function (){
            $list = [];
            $models = WorksType::all();
            foreach ($models as $model){
                $list[] = ['label' => $model->code . '-' . $model->name, 'value' => $model->id];
            }
            return $list;
        });
        return $selectList;
    }
}